# -*- coding:utf-8 -*-
# @Time:2023/3/8 16:11
# @Author: cevent
# @name=celery芹菜消息队列入口-生产者

import sys,os

from celery import Celery

# 配置消息存放容器redis(在10号库)，引入config成功，这里的可以取消
brokerUrl = "redis://:cevent619Rs@192.168.139.130:6379/10"
backEnd = "redis://:cevent619Rs@192.168.139.130:6379/11"

# 1.创建celery实例-生产者：('param')标识celery实例名称
celeryApp = Celery('yiDaoCelery')

# 2.加载中间人（消费者）配置
# celeryApp.config_from_object('celery_tasks.config')
celeryApp.config_from_object('config')
# celeryApp.config_from_object('config')

# 3.注册任务，参数 列表/数组 放入：任务所在目录
# celeryApp.autodiscover_tasks(['celery_tasks.sms'])
celeryApp.autodiscover_tasks(['sms'])


def celeryStart():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', '')

    # 2.加载中间人（消费者）配置
    celeryApp.config_from_object('celery_tasks.config')
    # celeryApp.config_from_object('config')

    # 3.注册任务，参数 列表/数组 放入：任务所在目录
    celeryApp.autodiscover_tasks(['celery_tasks.sms'])

    # celeryApp.autodiscover_tasks(['tasks'])


if __name__ == '__main__':
    print('celery 启动中......')
    celeryStart()
    print("celery 启动成功")
